package main

import ("fmt")
import ("net")
import ("net/http")
import ("net/http/httputil")
import ("net/url")

func main() {
    // 要解析的域名
    domain := "file.898311.xyz"

    // 解析域名的IPv6地址
    ips, err := net.LookupIP(domain)
    if err != nil {
        fmt.Println("Error:", err)
        return
    }

    // 打印解析出的IPv6地址
    for _, ip := range ips {
        if ip.To4() == nil {
            fmt.Println("IPv6 Address:", ip)
			domain =  ip.String()
        }
    }
	// Create a new reverse proxy
	proxy := httputil.NewSingleHostReverseProxy(&url.URL{
		Scheme: "http",
		Host:   "["+domain+"]"+":5244",
	})
	http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
        // 在请求之前修改请求的Host头部
        // r.Host = targetURL.Host
        proxy.ServeHTTP(w, r)
    })
    // 启动HTTP服务器
    fmt.Println("Reverse proxy listening on :8080")
    if err := http.ListenAndServe(":8080", nil); err != nil {
        fmt.Println("Error starting server:", err)
    }
}
